public class Solution343 {
    public int integerBreak(int n) {
        if (n <= 4) {
            if (n == 1 || n == 4) {
                return n;
            } else {
                return n - 1;
            }
        }
        int res = 1;
        while (n > 4) {
            res *= 3;
            n -= 3;
        }
        res *= n;
        return res;
    }
}
